package com.roc.steelend.service.Impl;

import com.roc.steelend.controller.vo.returnformat.EchartsMsg;
import com.roc.steelend.mapper.BuyOrderMapper;
import com.roc.steelend.mapper.KaipingOrderMapper;
import com.roc.steelend.mapper.SaleOrderMapper;
import com.roc.steelend.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(rollbackFor = Exception.class)
public class EchartsServiceImpl implements EchartsService {



    @Autowired
    private BuyOrderMapper buyOrderMapper;

    @Autowired
    private SaleOrderMapper saleOrderMapper;
    @Autowired
    private KaipingOrderMapper kaipingOrderMapper;
    @Override
    public List<EchartsMsg> getEchartsPaynopay() {

        List<EchartsMsg> list = new ArrayList<>();
//        采购

        EchartsMsg echartsMsg = new EchartsMsg();
        echartsMsg.setName("采购");
        echartsMsg.setValue(buyOrderMapper.selectByEchartsByPay());
        list.add(echartsMsg);
//      销售
        EchartsMsg echartsMsg1 = new EchartsMsg();
        echartsMsg1.setName("销售");
        echartsMsg1.setValue(saleOrderMapper.selectEchartsByPay());
        list.add(echartsMsg1);
//        开平
        EchartsMsg echartsMsg2 = new EchartsMsg();
        echartsMsg2.setName("开平");
        echartsMsg2.setValue(kaipingOrderMapper.selectEchartsByPay());
        list.add(echartsMsg2);

        return list;
    }

    @Override
    public List<EchartsMsg> getEchartsInvoice() {
        List<EchartsMsg> list = new ArrayList<>();
//        采购

        EchartsMsg echartsMsg = new EchartsMsg();
        echartsMsg.setName("采购");
        echartsMsg.setValue(buyOrderMapper.selectByEchartsInvoice());
        list.add(echartsMsg);
//      销售
        EchartsMsg echartsMsg1 = new EchartsMsg();
        echartsMsg1.setName("销售");
        echartsMsg1.setValue(saleOrderMapper.selectByEchartsByInvoice());
        list.add(echartsMsg1);
//        开平
        EchartsMsg echartsMsg2 = new EchartsMsg();
        echartsMsg2.setName("开平");
        echartsMsg2.setValue(kaipingOrderMapper.selectEchartsByInvoice());
        list.add(echartsMsg2);

        return list;
    }
}
